<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="12">
        <el-card class="update-log">
          <div slot="header" class="clearfix">
            <span>今日商家入驻数</span>
          </div>
          <div class="body">
            <p>{{ data.submitCount }} 家</p>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="12">
        <el-card class="update-log">
          <div slot="header" class="clearfix">
            <span>今日商家通过数</span>
          </div>
          <div class="body">
            <p>{{ data.okCount }} 家</p>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-divider />
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="12">
        <el-card class="update-log">
          <div slot="header" class="clearfix">
            <span>订单概览</span>
            <el-select v-model="selectDay" size="mini" style="float: right" placeholder="请选择日期" @change="getOrderData">
              <el-option v-for="item in dayOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </div>
          <div class="body" v-loading="loading">
            <ul class="one clearfix ">
              <li style="float:left;text-align: center">
                <h4 class="title">订单数量</h4>
                <p>{{ orderStatistics.orderCount }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">订单金额</h4>
                <p>{{ orderStatistics.orderAmount }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">平均客单价</h4>
                <p>{{ orderStatistics.orderAverage }}</p>
              </li>
            </ul>
            <ul class="one clearfix ">
              <li style="float:left;text-align: center">
                <h4 class="title">退款订单数量</h4>
                <p>{{ orderStatistics.refundCount }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">退款金额</h4>
                <p>{{ orderStatistics.refundAmount }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">退款积分</h4>
                <p>{{ orderStatistics.refundScore }}</p>
              </li>
            </ul>
            <ul class="one clearfix ">
              <li style="float:left;text-align: center">
                <h4 class="title">积分订单数量</h4>
                <p>{{ orderStatistics.scoreOrder }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">积分锁定</h4>
                <p>{{ orderStatistics.scorePay }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">积分兑换</h4>
                <p>{{ orderStatistics.scoreChange }}</p>
              </li>
            </ul>
            <ul class="one clearfix ">
              <li style="float:left;text-align: center">
                <h4 class="title">平台分润</h4>
                <p>{{ orderStatistics.platform }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">运营中心分润</h4>
                <p>{{ orderStatistics.operationProfit }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">DDS平台暂存</h4>
                <p>{{ orderStatistics.ddsChannelFee }}</p>
              </li>
              <li style="float:left;text-align: center">
                <h4 class="title">中投通道费</h4>
                <p>{{ orderStatistics.msfChannelFee }}</p>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getIndexData, getOrderData } from '@/api'

export default {
  name: "index",
  data() {
    return {
      data: {
        submitCount: 0,
        okCount: 0
      },
      dayOptions: [{
        value: 1,
        label: '今天'
      }, {
        value: 2,
        label: '昨天'
      }, {
        value: 7,
        label: '本周'
      }, {
        value: 30,
        label: '本月'
      }, {
        value: 90,
        label: '90天内'
      }],
      selectDay: 1,
      orderStatistics: {
        refundCount: 0,
        scoreChange: 0,
        orderAverage: 0,
        orderCount: 0,
        operationProfit: 0,
        platform: 0,
        msfChannelFee: 0,
        orderAmount: 0,
        scoreOrder: 0,
        scorePay: 0,
        ddsChannelFee: 0,
        refundAmount: 0,
        refundScore: 0
      },
      loading: false
    }
  },
  created() {
    this.getData();
    this.getOrderData(this.selectDay);
  },
  methods: {
    getData() {
      getIndexData().then(response => {
        this.data.okCount = response.data.okCount
        this.data.submitCount = response.data.submitCount
      })
    },
    getOrderData(selectDay) {
      this.loading = true;
      this.selectDay = selectDay;
      getOrderData(selectDay).then(response => {
        Object.assign(this.orderStatistics, response.data);
        this.loading = false;
      })
    }
  },
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
  .one{
    width:100%;
  }
  .one li{
    width:13.33%;
  }
}
</style>

